package pictureTCP;

import java.io.*;
import java.net.Socket;

public class Demo {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",10010);
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("D:\\picture\\yfz.jpg"));
        OutputStream os = socket.getOutputStream();
        byte[] bytes = new byte[1024];
        int len;
        while((len=bis.read(bytes))!=-1) {
            os.write(bytes,0,len);
        }
        socket.shutdownOutput();
        bis.close();

        //接收服务器上传结果
        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String line;
        while((line=br.readLine())!=null) {
            System.out.println(line);
        }
        br.close();
        socket.close();
    }
}
